<%@page import="cn.xiu.dang.service.impl.UserServiceImpl"%>
<%@page import="cn.xiu.dang.pojo.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
  <head>
    <%-- <base href="<%=basePath%>"> --%>
    <meta charset="UTF-8">
    <title>处理注册表</title>
  </head>
  <body>
    <%
    //将请求编码设置为utf-8
    request.setCharacterEncoding("utf-8");
    //获取email数据
    String email=request.getParameter("email");
    String username=request.getParameter("username");
    String sex=request.getParameter("sex");
    String pwd=request.getParameter("password");
    //创建对象 
   User user=new User(username, pwd, email, sex);
   //创建用户业务实现对象
   UserServiceImpl usi=new UserServiceImpl();
  int result= usi.register(user);
  if(result==1){
  
    response.sendRedirect("../index.jsp");
    }else if(result==0){
    out.println("<script>alert('已有此用户');location.href='../index.jsp';</script>");
    
    }else if(result==-1){
    out.println("<script>alert('注册失败');location.harf='../index.jsp';</script>");
    }
     %>
    
  </body>
</html>
